package com.bsoft.controller.Faount;

import com.bsoft.Producer.Fanout.Demo03Producer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.CountDownLatch;

@RestController
@Slf4j
public class Demo03Controller {

    @Autowired
    private Demo03Producer producer;

    @GetMapping("/testFanout")
    public void testFanout() throws InterruptedException {
        int id = (int) (System.currentTimeMillis() / 1000);
        producer.syncSend(id);
        log.info("{testSysnSend {发送编号}", id);
        //阻塞等待 保证消费
        new CountDownLatch(1).await();
    }
}
